/**
 * FileContentManager is a Java based file manager desktop application, it can
 * show, edit and manipulate the content of the files archived inside a zip.
 * 
 * Copyright (C) 2007
 * 
 * Created by Camila Sanchez [http://mimix.wordpress.com/], Rafael Naufal
 * [http://rnaufal.livejournal.com] and Rodrigo [rdomartins@gmail.com]
 * 
 * FileContentManager is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with FileContentManager; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
/*
 * Created on 26/05/2007 14:00:05
 */
package br.com.jteam.jfcm.gui;

import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * <p>
 * Classe respons&aacute;vel por manter e gerenciar o a
 * apresenta&ccedil;&atilde;o do hist&oacute;rico de arquivos.
 * 
 * @author Rafael Naufal <rafael.naufal@gmail.com>
 * @since 1.0
 * @version $Id$
 */
public class PresentationFileHistory implements Iterable<PresentationFile<?>>
{
	/**
	 * <p>
	 * Lista respons&aacute;vel por manter os �ltimos arquivos do
	 * hist&oacute;rico para apresenta&ccedil;&atilde;o.
	 */
	private List<PresentationFile<?>> files;

	/**
	 * <p>
	 * Construtor sem argumentos. Inicializa a lista de arquivos para
	 * apresenta&ccedil;&atilde;o.
	 */
	public PresentationFileHistory()
	{
		files = new LinkedList<PresentationFile<?>>();
	}

	/**
	 * <p>
	 * Adiciona um arquivo no hist&oacute;rico de arquivos.
	 * 
	 * @param file
	 *            arquivo a ser adicionado no hist&oacute;rico. Caso o arquivo
	 *            seja nulo, nada &eacute; feito.
	 */
	public void add(PresentationFile<?> file)
	{
		if (file == null)
		{
			return;
		}
		files.add(file);
	}

	/**
	 * <p>
	 * Produz um <code>iterator</code> da lista de arquivos para
	 * apresenta&ccedil;&atilde;o do hist&oacute;rico corrente.
	 * 
	 * @return iterator da lista criado.
	 */
	public Iterator<PresentationFile<?>> iterator()
	{
		List<PresentationFile<?>> unmodifiableFiles =
						Collections.unmodifiableList(files);
		return (Iterator<PresentationFile<?>>) unmodifiableFiles.iterator();
	}
}
